package com.GetIp;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class Main94 {
    public static void main(String[] args){
        try{
            InetAddress localHost = InetAddress.getLocalHost();
            String hostName = localHost.getHostName();
            System.out.println("本机的主机名："+hostName);
            String hostAddress = localHost.getHostAddress();
            System.out.println("本机的IP地址："+hostAddress);
        }catch (UnknownHostException e){
            System.out.println("无法获取主机名或IP地址");
        }
    }

}
